var vm=new Vue({
    el: "#app",
    data:{
        percent:0,
        showProgress:false,
        path:'',
        user:'',
        fileList:[]
    },
    methods:{
        initFile(path){
            axios({
                method: "post",
                url: "/getFiles.do",
                params: {
                    id:this.user.id,
                    path:path||""
                },
            }).then(function (res) {
                vm.fileList=res.data.data
                vm.path=res.data.data[0].path
            })
        },
        clickFolder(item){
            this.initFile(item.path);
        },
        downloadFile(item){
            window.open('/downloadFile.do?path='+this.encodeUrl(item.path));
        },
        encodeUrl(path){
            return encodeURI(path);
        },
        uploadSuccess(res){
            this.$message(res.msg);
            this.initFile(this.path);
        },
        onUpload(event, file, fileList){
            let loadProgress = Math.floor(event.percent) //这就是当前上传的进度
            if (loadProgress != 100) {
                this.showProgress=true;
                this.percent = parseInt(loadProgress);
            }else {
                this.showProgress=false;
                this.percent=0;
            }

        }

    },
    mounted:function () {
        var user=localStorage.getItem("user");
        if (user != null) {
            this.user=JSON.parse(user);
        }
        this.initFile();
    }
})